package com.yoomiito.app.ui.college.list

import cn.droidlover.xdroidmvp.net.ApiException
import cn.droidlover.xdroidmvp.net.ApiSubscriber
import cn.droidlover.xdroidmvp.net.XApi
import com.yoomiito.app.base.AppConfig
import com.yoomiito.app.base.BaseActPresenter
import com.yoomiito.app.model.BaseList
import com.yoomiito.app.model.colleage.Subject
import com.yoomiito.app.net.YmApi

class CollegeSubjectPresenter(appConfig: AppConfig) :BaseActPresenter<CollegeSubjectActivity>(appConfig){

    fun queryList(page:Int){
        YmApi.getYmService().queryColleageSubjectList(page)
                .compose(v.bindToLifecycle())
                .compose(XApi.getApiTransformerData())
                .compose(XApi.getScheduler())
                .subscribe(object : ApiSubscriber<BaseList<Subject>>(handleException()){
                    override fun onSuccess(t: BaseList<Subject>?) {
                        v.setData(t!!)
                    }

                    override fun onFail(error: ApiException?) {

                    }

                })
    }
}